package com.hmall.common.index;

import org.apache.http.HttpHost;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;

import java.io.IOException;

public class ShopIndex {

    private RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(
            HttpHost.create("http://192.168.138.100:5601")
    ));

    /**
     * 创建索引库
     * @throws IOException
     */

    public void createIndex() throws IOException {
        CreateIndexRequest request = new CreateIndexRequest("shop");
        request.source(cl.createIndex, XContentType.JSON);
        client.indices().create(request, RequestOptions.DEFAULT);
    }







}
